package cn.stylefeng.guns.modular.gridsystem.timer;

import cn.stylefeng.guns.core.context.constant.ConstantContextHolder;
import cn.stylefeng.guns.core.timer.TimerTaskRunner;
import cn.stylefeng.guns.modular.gridsystem.constants.UplaodFolderConstant;
import cn.stylefeng.guns.modular.gridsystem.utils.MyFileUtils;
import org.springframework.stereotype.Component;

/**
 * 删除指定目录的指定天数前的文件定时任务
 */
@Component
public class AutoDeleteFileTaskRunner implements TimerTaskRunner {

    @Override
    public void action() {
        int daysThreshold = ConstantContextHolder.getDaysThreshold();
        //网关样本文件目录
        String gatewayPath = MyFileUtils.getUploadPath() + "/" + UplaodFolderConstant.GATEWAY_SAMPLE_AUDIO_FOLDER;
        MyFileUtils.cleanupFiles(gatewayPath,daysThreshold);
        //故障文件目录
        String faultPath = MyFileUtils.getUploadPath() + "/" + UplaodFolderConstant.FAILURE_AUDIO_FOLDER;
        MyFileUtils.cleanupFiles(faultPath,daysThreshold);
    }

}
